package com.qf.smsplatform.gateway.config;

import com.qf.smsplatform.common.constants.RabbitMQConstants;
import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: LeeRui
 * 2021/2/5 上午 1:18
 * 网关模块发送消息到MQ队列，webmaster进行监听获取消息进行Redis和数据库中费用操作
 **/
@Configuration
public class FeeRabbitConfig {

    // 交换机
    @Bean
    public Exchange preSendExchange(){
        return ExchangeBuilder.topicExchange(RabbitMQConstants.SMS_FEE_SEND_TOPIC+ "_exchange").build();
    }

    // 队列
    @Bean
    public Queue preSendQueue(){
        return QueueBuilder.durable(RabbitMQConstants.SMS_FEE_SEND_TOPIC).build();
    }

    // 绑定
    @Bean
    public Binding preSendBinding(Queue preSendQueue, Exchange preSendExchange){
        return BindingBuilder.bind(preSendQueue).to(preSendExchange).with("#").noargs();
    }
}
